package C;

import java.util.Arrays;
import java.util.Scanner;

public class C21 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        System.out.println(getResult(line));
    }

    public static int getResult(String line) {
        int[] cards = Arrays.stream(line.split(",")).mapToInt(Integer::parseInt).toArray();
        int n = cards.length;
        int[] dp = new int[n];
        for (int i=0;i<n;i++) {
            if (i==0) {
                dp[i] = Math.max(0,cards[i]);
            } else if (i<3) {
                dp[i] = Math.max(0,cards[i]+dp[i-1]);
            } else {
                dp[i] = Math.max(dp[i-3],cards[i]+dp[i-1]);
            }
        }
        return dp[n-1];
    }
}
